﻿using System.Net;
using Newtonsoft.Json;

namespace iOSClub.App.Share.Serves;

public class iOSServer : IServer
{
    public iOSServer()
    {
    }

    public iOSServer(string jwt) : base(jwt)
    {
    }

    public iOSServer(IServer server) : base(server)
    {
    }

    public async Task<List<MemberModel>> GetStudents()
    {
        try
        {
            using var result = await httpClient.GetAsync($"{_url}/President/GetAllData");
            if (result.StatusCode == HttpStatusCode.BadGateway) return [];
            var memberJsonData = await result.Content.ReadAsStringAsync();
            return JsonConvert.DeserializeObject<List<MemberModel>>
                (GZipServer.DecompressString(memberJsonData)) ?? [];
        }
        catch
        {
            return [];
        }
    }
}